<%@ Control%>
		<div id="Body">
	<div id="CommonCenter">
		<div id="Center9002">
			<div id="Center9002Left">
				<!--forums & resources link start-->
				<div id="Info2Area">
					<div id="Top"><img src="/Images/My_Info_STop.gif" /></div>
					<div id="Middle">
						<div id="Content"><img src="/Images/icon_feed_recommand.gif" align="absmiddle" /> <strong>Recommend an RSS Feed</strong></div>
						<div id="Content">Have you found an interesting language learning blog or podcast? Recommend them to the italki community!</div>
						<div id="Content"><input id="rssUrl" type="text" class="common180" value="Enter the RSS Feed URL" onblur="if (this.value=='') this.value='Enter the RSS Feed URL';" onfocus="if (this.value=='Enter the RSS Feed URL') this.value='';" /></div>
						<div id="Content"><strong>For Learning: </strong>
							<div id="learnDiv"></div>
						</div>
						<div id="Content"><strong>Base Language: </strong>
                            <div id="nativeDiv"></div>
						</div>
						<div id="Content"><input type="button" id="RssAdd" value="Recommend" onClick="AddRss()" class="button" /></div>
					</div>
					<div id="Bottom"></div>
				</div>
				<!--forums & resources link end-->
			</div>
			<div id="Center9002Right">
				<!--rss started-->
				<!--loop started-->
				<div id="Center9002Content">
					<div id="ContentTitle">
						<div style="float:left" class="Black14B">Browse Language Learning Feeds</div>
						<div style="float:right"></div>
					</div>
					<div id="error" style=" border:3px #EDF1FE solid; width:624px!important;width:100%">
						<h3>Get started quickly by selecting one of our language bundles</h3>
						<p>The easiest way to find some useful language learning feeds is to subscribe to one of our pre-packaged language bundles.
                        <br />You can always add or remove individual feeds in our edit feeds section.
                        <br />Note: Much of the content in this directory was developed by other companies or by italki's users, not by italki. italki makes no promises or representations about its performance, quality, or content. </p>
						<div id="rsslist" style="border-top:1px #eeeeee solid; border-bottom:1px #eeeeee solid; background-color:#FDFAE1; padding:5px">
							<div style="float:left; padding:3px"><strong>For Learning: </strong><div id="learnSeachDiv"></div></div>
							<div style="float:left; padding:3px"><strong>Base Language: </strong><div id="nativeSeachDiv"></div></div>
							<div style="float:left; padding:19px 0px 0px 3px"><input type="button" id="btnBrowse" value="Browse" onClick="Seach()" class="button" /></div>
							<div class="clear"></div>
						</div>
					</div>
					<div id='divSeachLoading' style="display:none" class="Loading_Notice"><img src="/Images/loading.gif" align="absmiddle"> Loading...</div>
					<div id="RssContent"></div>
				</div>
				<!--loop end-->
				<!--rss end-->
			</div>
			<div class="clear"></div>
		</div>
	</div>
</div>
<script language="javascript" type="text/javascript">
var nativeLang = "English";
var learnLang  =  "Chinese";
var getLang = new Ajax.Request
('/GetRss.aspx?do=6',
  {
    method: 'post',
    evalScripts: true,
    onComplete: UpdateLang
  }
);
function UpdateLang(response)
{
    var tmp = response.responseText.split(",");
    nativeLang = tmp[0];
    learnLang = tmp[1];
}
var UpdateObject = Class.create();
UpdateObject.prototype = 
{
  initialize: function(id,obj) 
  {
    this.id = id;
    this.obj = obj;
  },
  Update: function(response) 
  {
    if(this.obj==null) 
    {
        if(response.responseText!="0")
        {
            $(this.id).innerHTML = response.responseText;
        }
    }
    
    if(this.id=="nativeDiv")
    {
        $("nativeSel").value = nativeLang;
        
    }
    else if(this.id=="learnDiv")
    {
        $("learnSel").value = learnLang;
    }
    else if(this.id=="learnSeachDiv")
    {
        $("learnSeachSel").value = learnLang;
    }
    else
    {
        if(response.responseText=="0")
        {
            this.obj.disabled = "";
            alert("Subscribe failed.");
        }
        else
        {
           Element.remove(this.obj);
        }
    }
  }
}
var updateObject1 = new UpdateObject("learnDiv",null);
var sel1 = new Ajax.Request
(
    '/GetRss.aspx?do=4&selectName=learnSel&fileName=Languages.xml&valueIndex=0&textIndex=1&AddValue=All&AddText=All', 
    {
        method: 'get',
        evalScripts: true,
        onComplete: updateObject1.Update.bind(updateObject1)
    }
);
var updateObject2 = new UpdateObject("nativeDiv",null);
var sel2 = new Ajax.Request
(
    '/GetRss.aspx?do=4&selectName=nativeSel&fileName=Languages.xml&valueIndex=0&textIndex=1&AddValue=All&AddText=All', 
    {
        method: 'get',
        evalScripts: true,
        onComplete: updateObject2.Update.bind(updateObject2)
    }
);
var updateObject3 = new UpdateObject("learnSeachDiv",null);
var sel1 = new Ajax.Request
(
    '/GetRss.aspx?do=4&selectName=learnSeachSel&fileName=Languages.xml&valueIndex=0&textIndex=1&AddValue=All&AddText=All', 
    {
        method: 'get',
        evalScripts: true,
        onComplete: updateObject3.Update.bind(updateObject3)
    }
);
var updateObject4 = new UpdateObject("nativeSeachDiv",null);
var sel2 = new Ajax.Request
(
    '/GetRss.aspx?do=4&selectName=nativeSeachSel&fileName=Languages.xml&valueIndex=0&textIndex=1&AddValue=All&AddText=All', 
    {
        method: 'get',
        evalScripts: true,
        onComplete: updateObject4.Update.bind(updateObject4)
    }
);
function AddRss()
{
    var strRssUrl = $("rssUrl").value.strip();
    var re = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?$/i;
    if(strRssUrl==""||strRssUrl.search(re)==-1)
    {
        alert("Please check your RSS address.");
        return;
    }
    $("RssAdd").disabled = "disabled";
    var obj1 = $("learnSel");
    var obj2 = $("nativeSel");
    if(obj1&&obj2)
    {
        var myAjax = new Ajax.Request
        ('/GetRss.aspx?do=5&learnSel='+obj1.options[obj1.selectedIndex].value+'&nativeSel='+obj2.options[obj2.selectedIndex].value+'&url='+strRssUrl,
          {
            method: 'post',
            evalScripts: true,
            onComplete: UpdateRssFeed,
            onCreate:SeachLoading
          }
        );
    }
}
function UpdateRssFeed(response)
{
    Element.hide('divSeachLoading');   
    $("RssAdd").disabled = "";
    if(response.responseText=="0")
    {
        alert("Add failed.");
    }
    else
    {
        $("rssUrl").value = "";
    }
    
}
function UpdateSeach(pageIndex,pageSize)
{
    $("btnBrowse").disabled = "disabled";
    var obj1 = $("learnSeachSel");
    var obj2 = $("nativeSeachSel");
    var strLearn = "English";
    var strNative = "All";
    if(obj1) strLearn = obj1.value;
    if(obj2) strNative = obj2.value;
    var myAjax = new Ajax.Request
    ('/GetRss.aspx?do=7&learnSel='+strLearn+'&nativeSel='+strNative+'&pageIndex='+pageIndex+'&pageSize='+pageSize,
      {
        method: 'post',
        evalScripts: true,
        onComplete: UpdateContent,
        onCreate:SeachLoading
      }
    );
}
function Seach()
{
    UpdateSeach(1,10);
}
function SeachLoading(response)
{
    Element.show('divSeachLoading');
}
function UpdateContent(response)
{
    Element.hide('divSeachLoading');
    $("btnBrowse").disabled = "";
    if(response.responseText!="0") 
    {
        $("RssContent").innerHTML = response.responseText;
    }
    else
    {
        $("RssContent").innerHTML = "";
    }
}

function subscribe(url,obj)
{
    var updateObject5 = new UpdateObject("",obj);
    obj.disabled = "disabled";
    var myAjax = new Ajax.Request
    ('/GetRss.aspx?do=8&url='+url,
      {
        method: 'post',
        evalScripts: true,
        onComplete: updateObject5.Update.bind(updateObject5)
      }
    );
}

function PageRss(pageIndex)
{
    UpdateSeach(pageIndex,10);
}
Seach();
</script>
